package ru.mipt.testload.util;

import com.sun.xml.xsom.XSType;
import org.jdesktop.swingx.renderer.StringValue;

/**
 * @author Pavel G. Belevich
 *         Date: 18.06.2010
 *         Time: 2:03:28
 */
public class XSTypeStringValue implements StringValue {
    public String getString(Object value) {
        XSType xsType = (XSType) value;
        String result = xsType.getName();
        if (xsType.isSimpleType()) {
            if (!"http://www.w3.org/2001/XMLSchema".equals(xsType.getTargetNamespace())) {
                result += "(" + xsType.asSimpleType().getSimpleBaseType().getName() + ")";
            }
        }
        return result;
    }
}
